/**
 * 
 */
package com.scpii.universal.hibernate.dao.impl;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Repository;

import com.scpii.universal.constant.GenericConstants;
import com.scpii.universal.hibernate.dao.PageNavigationDao;
import com.scpii.universal.hibernate.entity.PageNavigationTab;

/**
 * universalWeb
 * @author liuhj
 * 2012-7-23下午09:59:28
 */
@Repository
public class PageNavigationDaoImpl extends BaseDaoImpl<PageNavigationTab, Integer> implements PageNavigationDao {

	@Override
	public void delete(Integer id) {
		String hql = "update PageNavigationTab p set p.intDeleteSign=?,p.datUpdateDatetime=? where p.intNavigateId=?";
		getHibernateTemplate().getSessionFactory().getCurrentSession()
				.createQuery(hql).setParameter(0,
						GenericConstants.DELETE_SIGN_DELETED).setParameter(1,
						new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
								.format(new Date())).setParameter(2, id).executeUpdate();
	}

	@Override
	public PageNavigationTab getNavInfoById(int navId, String[] properties) {
		String hql = generateHqlByProperties(properties)
				+ "where entity.intNavigateId=?";
		return (PageNavigationTab) getHibernateTemplate().getSessionFactory()
				.getCurrentSession().createQuery(hql).setParameter(0, navId)
				.uniqueResult();
	}
	
}
